package com.semlab.client.mvp.home;

import java.util.List;

import com.google.inject.Inject;
import com.semlab.client.app.Application;
import com.semlab.client.fwk.ap.ActivityRegistry;
import com.semlab.client.fwk.ap.Place;
import com.semlab.client.fwk.ap.mvp.BaseMVP;
import com.semlab.client.proxy.ClientProxy;
import com.semlab.client.proxy.MoviePageProxy;
import com.semlab.client.proxy.MovieProxy;
import com.semlab.client.req.RequestFactory;
import com.semlab.client.widgets.SocialClient;
import com.semlab.client.widgets.UICallback;


public class HomeMVP extends BaseMVP {
	
	public static final String ACTIVITY_ID = "home";
	
	public static Place place() {
		return new Place(Application.WORKSPACE_CONTAINER_ID, ACTIVITY_ID);
	}
	
	public static interface View extends BaseMVP.View<Presenter> {
        public void refreshMoviesExplorer();

        void showMoviesExplorer();
    }
	
	public static interface Presenter extends BaseMVP.Presenter<View> {

		void startImport(int numOfFriends, int numOfMovies);

		void getAllMovies(UICallback<MoviePageProxy> callback, int offset, int num);

		void getFriendsForAMovie(MovieProxy proxy, UICallback<List<ClientProxy>> friendsCallback);

		void getDetailsForAMovie(MovieProxy proxy, UICallback<MovieProxy> callback);

        void enrichMovieData(MovieProxy movie, UICallback<MovieProxy> detailsCallback);

    }
	
	private HomeView view;

	@Inject
	public HomeMVP(ActivityRegistry registry, final RequestFactory factory) {
		super(registry);
		mapPlaces(place()).to(new Factory<Presenter>() {
			@Override
			public Presenter create(Place place) {
				if(view == null) {
					view = new HomeView();
				}
				return new HomePresenter(place, view, factory); 
			}
		});
	}
}
